<script setup lang="ts">
import SpaceUsageAnalyze from '@/components/analyze/SpaceUsageAnalyze.vue'
import SpaceCategoryAnalyze from '@/components/analyze/SpaceCategoryAnalyze.vue'
import SpaceTagAnalyze from '@/components/analyze/SpaceTagAnalyze.vue'
import SpaceSizeAnalyze from '@/components/analyze/SpaceSizeAnalyze.vue'
import SpaceUserAnalyze from '@/components/analyze/SpaceUserAnalyze.vue'
import SpaceRankAnalyze from '@/components/analyze/SpaceRankAnalyze.vue'
import { useLoginUserStore } from '@/stores/userLoginUserStore.ts'
import { useRoute, useRouter } from 'vue-router'
import { computed } from 'vue'

const loginUserStore = useLoginUserStore()
const route = useRoute()

const spaceId = computed(() => {
  return route.query?.spaceId as string
})

const queryAll = computed(() => {
  return !!route.query?.queryAll
})

const queryPublic = computed(() => {
  return !!route.query?.queryPublic
})

</script>

<template>
  <a-row :gutter="[16, 16]">
    <a-col :md="12" :xs="24">
      <SpaceUsageAnalyze :query-all="queryAll" :query-public="queryPublic" :space-id="spaceId"></SpaceUsageAnalyze>
    </a-col>

    <a-col :md="12" :xs="24">
      <SpaceCategoryAnalyze :query-all="queryAll" :query-public="queryPublic" :space-id="spaceId"></SpaceCategoryAnalyze>
    </a-col>

    <a-col :md="12" :xs="24">
      <SpaceTagAnalyze :query-all="queryAll" :query-public="queryPublic" :space-id="spaceId"></SpaceTagAnalyze>
    </a-col>

    <a-col :md="12" :xs="24">
      <SpaceSizeAnalyze :query-all="queryAll" :query-public="queryPublic" :space-id="spaceId"></SpaceSizeAnalyze>
    </a-col>

    <a-col :md="12" :xs="24">
      <SpaceUserAnalyze :query-all="queryAll" :query-public="queryPublic" :space-id="spaceId"></SpaceUserAnalyze>
    </a-col>

    <a-col :md="12" :xs="24" v-if="loginUserStore.loginUser.userRole === 'admin' && queryAll">
      <SpaceRankAnalyze :query-all="queryAll" :query-public="queryPublic" :space-id="spaceId"></SpaceRankAnalyze>
    </a-col>
  </a-row>
</template>

<style scoped></style>
